import React,{useImperativeHandle, forwardRef} from 'react'
import {useRecoilState,useRecoilValue} from 'recoil'
import {getDemoState} from '@selectors/selectDemo'
import {demoState} from '@atoms/atomsDemo'


const Demo = (_props: any,ref: React.Ref<unknown> | undefined) => {
    const d = useRecoilValue(getDemoState)
    const [count, setDemo] = useRecoilState(demoState);
    useImperativeHandle(ref, () => ({
        // changeVal 就是暴露给父组件的方法
        changeVal: (newVal: any) => {
           
        }
    }));
    return (
        <>
        <p>{d}~~~~</p>
        <p onClick={()=>setDemo(100)}>90{count}</p>
        </>
    )
}
export default forwardRef(Demo)